from rest_framework import serializers
from .models import Area

# 1,上级行政区信息
class AreInfoSerializer(serializers.ModelSerializer):

    class Meta:
        model = Area
        fields = ("id", "name")

# 2,子级的行政区域信息
class AreaSubsInfoSerializer(serializers.ModelSerializer):
    subs = AreInfoSerializer(read_only=True, many=True)

    class Meta:
        model = Area
        fields = ("id", "name", "subs")